using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class Category : EveProperty
    {
        private string categoryName;
        private string description;
        private int graphicId;
        private bool published; // rev 2.0 only

        private Graphic graphic;

        public string Name
        {
            get { return categoryName; }
        }
        public string Description
        {
            get { return description; }
        }
        public Graphic Graphic
        {
            get
            {
                if (graphic == null)
                    graphic = new Graphic(db, graphicId);
                return graphic;
            }
        }
        public bool Published
        {
            get { return published; }
        } // rev 2.0 only

        internal Category(DbDataRow dr)
            : base(dr.Database, EvePropertyType.Category, dr["categoryID"])
        {
            Fill(dr);
        }
        internal Category(Database db, int id)
            : base(db, EvePropertyType.Category, id)
        {
            Fill(db.ExecuteSingle("SELECT * FROM invCategories WHERE categoryID=" + id));
        }

        private void Fill(DbDataRow dr)
        {
            categoryName = dr["categoryName"];
            description = dr["description"];
            graphicId = dr["graphicID"];
            published = dr["published"];
        }
    }
}
